<template>
	<view>
		<view>新闻列表页</view>
		<view v-if="news.length==0">加载中...</view>
		<!-- <view v-for="item in news" :key="item.key"> -->
			<!-- 此时的详情页，设置了底部菜单，而设置底部菜单的页面只能通过 open-type=switchTab才能跳转-->
			<!-- <navigator :url="'../detail/detail?id='+item.id">{{item.title}}</navigator> -->
		<!-- </view> -->
		<uni-list>
		    <uni-list-item v-for="item in news" :key="item.key"  :title="item.title" />
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				news: []
			}
		},
		async mounted() {
			let [, ret] = await uni.request({
				url: 'https://mpapi.iynn.cn/api/v1/news'
			})
			let res = ret.data.data.data
			res = res.map(item => {
				item['key'] = 'news_' + item.id
				return item
			})
			this.news = res
		}
	}
</script>

<style lang="scss" scoped>
</style>
